Component({
    properties: {},
    data: {
        root: wx.getStorageSync('root') == 1 ? wx.getStorageSync('root') : 0,
        selected: 0,
        tabList: [{
                "pagePath": "pages/home/index/index",
                "text": "首页",
            },
            {
                "pagePath": "pages/post/index/index",
                "text": "发布"
            },
            {
                "pagePath": "pages/about/index/index",
                "text": "我的"
            }
        ]
    },
    methods: {
        switchTab(e) {
            this.setData({
                root: wx.getStorageSync('root'),
            })
            console.log(this.data)
            let key = Number(e.currentTarget.dataset.index);
            let tabList = this.data.tabList;
            let selected = this.data.selected;
            if (selected !== key) {
                this.setData({
                    selected: key
                });
                wx.switchTab({
                    url: `/${tabList[key].pagePath}`,
                })
            }
        }
    }
})